#!/bin/bash
source experiment.cfg
echo "Starting node instances"
aws ec2 run-instances --image-id $node_image --count $node_count --instance-type $instance_type --key-name $key_name --security-groups $security_groups | grep InstanceId | tr -cs 'a-zA-Z0-9.-' '[\n*]' | grep "i-" > $node_instanceid_file
echo "Sleeping to let nodes warm up"
sleep 5
echo "Saving nodes' public DNS names"
rm -f $node_dns_file
cat $node_instanceid_file | while read line;
do
	aws ec2 describe-instances --instance-ids ${line} | grep PublicDns | tr -cs 'a-zA-Z0-9.-' '[\n*]' | grep ec2 >> $node_dns_file
done
